package com.tegistuff.webos.run.debugger.commands;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * WebOSSetExceptionBreakCommand.java
 *
 * This command tells the debugger to stop on uncaught exceptions.
 *
 * Copyright (C) 2012 Timo Tegtmeier.
 * All rights reserved.
 */
public class WebOSSetExceptionBreakCommand extends WebOSDebuggerCommand {

    private boolean myState;

    public WebOSSetExceptionBreakCommand(boolean state) {
        myState = state;
    }

    @Override
    public void execute() throws Exception {
        JSONObject args = new JSONObject();
        args.put("type", "uncaught");
        args.put("enabled", myState);
        JSONObject request = new JSONObject();
        request.put("command", "setexceptionbreak");
        request.put("arguments", args);
        runRequest(request);
    }

    @Override
    protected void onSuccess() throws JSONException {
        // nothing to do here
    }
}
